

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Introduction &mdash; alsaaudio v0.7 documentation</title>
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '0.7',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="alsaaudio v0.7 documentation" href="index.html" />
    <link rel="next" title="PCM Terminology and Concepts" href="terminology.html" />
    <link rel="prev" title="alsaaudio documentation" href="index.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="terminology.html" title="PCM Terminology and Concepts"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="index.html" title="alsaaudio documentation"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">alsaaudio v0.7 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="introduction">
<h1>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h1>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Author:</th><td class="field-body">Casper Wilstrup</td>
</tr>
<tr class="field"><th class="field-name">Author:</th><td class="field-body">Lars Immisch</td>
</tr>
</tbody>
</table>
<p id="front">This software is licensed under the PSF license - the same one used by the
majority of the python distribution. Basically you can use it for anything you
wish (even commercial purposes). There is no warranty whatsoever.</p>
<div class="topic">
<p class="topic-title first">Abstract</p>
<p>This package contains wrappers for accessing the ALSA API from Python. It is
currently fairly complete for PCM devices and Mixer access. MIDI sequencer
support is low on our priority list, but volunteers are welcome.</p>
<p>If you find bugs in the wrappers please use the SourceForge bug tracker.
Please don&#8217;t send bug reports regarding ALSA specifically. There are several
bugs in this API, and those should be reported to the ALSA team - not me.</p>
</div>
</div>
<div class="section" id="what-is-alsa">
<h1>What is ALSA<a class="headerlink" href="#what-is-alsa" title="Permalink to this headline">¶</a></h1>
<p>The Advanced Linux Sound Architecture (ALSA) provides audio and MIDI
functionality to the Linux operating system.</p>
<p>Logically ALSA consists of these components:</p>
<ul class="simple">
<li>A set of kernel drivers. &#8212;  These drivers are responsible for handling the
physical sound  hardware from within the Linux kernel, and have been the
standard sound implementation in Linux since kernel version 2.5</li>
<li>A kernel level API for manipulating the ALSA devices.</li>
<li>A user-space C library for simplified access to the sound hardware from
userspace applications. This library is called <em>libasound</em> and is required by
all ALSA capable applications.</li>
</ul>
<p>More information about ALSA may be found on the project homepage
<a class="reference external" href="http://www.alsa-project.org">http://www.alsa-project.org</a></p>
<div class="section" id="alsa-and-python">
<h2>ALSA and Python<a class="headerlink" href="#alsa-and-python" title="Permalink to this headline">¶</a></h2>
<p>The older Linux sound API (OSS) which is now deprecated is well supported from
the standard Python library, through the ossaudiodev module. No native ALSA
support exists in the standard library.</p>
<p>There are a few other &#8220;ALSA for Python&#8221; projects available, including at least
two different projects called pyAlsa. Neither of these seem to be under active
development at the time - and neither are very feature complete.</p>
<p>I wrote PyAlsaAudio to fill this gap. My long term goal is to have the module
included in the standard Python library, but that looks currently unlikely.</p>
<p>PyAlsaAudio hass full support for sound capture, playback of sound, as well as
the ALSA Mixer API.</p>
<p>MIDI support is not available, and since I don&#8217;t own any MIDI hardware, it&#8217;s
difficult for me to implement it. Volunteers to work on this would be greatly
appreciated.</p>
</div>
</div>
<div class="section" id="installation">
<h1>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h1>
<p>Note: the wrappers link with the alsasound library (from the alsa-lib package)
and need the ALSA headers for compilation.  Verify that you have
/usr/lib/libasound.so and /usr/include/alsa (or similar paths) before building.</p>
<p><em>On Debian (and probably Ubuntu), install libasound2-dev.</em></p>
<p>Naturally you also need to use a kernel with proper ALSA support. This is the
default in Linux kernel 2.6 and later. If you are using kernel version 2.4 you
may need to install the ALSA patches yourself - although most distributions
ship with ALSA kernels.</p>
<p>To install, execute the following:  &#8212;</p>
<div class="highlight-python"><pre>$ python setup.py build</pre>
</div>
<p>And then as root:  &#8212;</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># python setup.py install</span>
</pre></div>
</div>
</div>
<div class="section" id="testing">
<h1>Testing<a class="headerlink" href="#testing" title="Permalink to this headline">¶</a></h1>
<p>First of all, run:</p>
<div class="highlight-python"><pre>$ python test.py</pre>
</div>
<p>This is a small test suite that mostly performs consistency tests. If
it fails, please file a <a class="reference external" href="http://sourceforge.net/tracker/?group_id=120651">bug report</a>.</p>
<p>To test PCM recordings (on your default soundcard), verify your
microphone works, then do:</p>
<div class="highlight-python"><pre>$ python recordtest.py &lt;filename&gt;</pre>
</div>
<p>Speak into the microphone, and interrupt the recording at any time
with <tt class="docutils literal"><span class="pre">Ctl-C</span></tt>.</p>
<p>Play back the recording with:</p>
<div class="highlight-python"><pre>$ python playbacktest.py &lt;filename&gt;</pre>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Introduction</a></li>
<li><a class="reference internal" href="#what-is-alsa">What is ALSA</a><ul>
<li><a class="reference internal" href="#alsa-and-python">ALSA and Python</a></li>
</ul>
</li>
<li><a class="reference internal" href="#installation">Installation</a></li>
<li><a class="reference internal" href="#testing">Testing</a></li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="index.html"
                        title="previous chapter">alsaaudio documentation</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="terminology.html"
                        title="next chapter">PCM Terminology and Concepts</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/pyalsaaudio.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="terminology.html" title="PCM Terminology and Concepts"
             >next</a> |</li>
        <li class="right" >
          <a href="index.html" title="alsaaudio documentation"
             >previous</a> |</li>
        <li><a href="index.html">alsaaudio v0.7 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2008-2009, Casper Wilstrup, Lars Immisch.
      Last updated on Aug 09, 2011.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.1.
    </div>
  </body>
</html>